package Verktoy;

import java.sql.Time;
import javax.faces.bean.ManagedBean;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

/**
 * Klasse som konverterer tid mellom string og object
 * @author Gruppe1
 */
@ManagedBean(name="tid")
public class TimeConverter implements Converter{

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        String [] lol = value.split(":");
        return lol.length != 3 || value == null || value.equals("") ? null : Time.valueOf(value);
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        return value.toString();
    }

}
